package com.jinsi.service.ylt.iml;

import com.jinsi.mapper.ylt.UserSealMapper;
import com.jinsi.service.ylt.UserSealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/*
    2022-08-04
    Ylt
    用户封号service接口实现类
 */

/**
 * @ClassName UserSealServiceImpl
 * @Content 用户封号service接口实现类
 * @Author 姚龙腾
 * @Date 2022/10/12 11:53
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class UserSealServiceImpl implements UserSealService {
    @Autowired
    private UserSealMapper userSealMapper;

    /**
     *
     * 获取全部用户封号信息
     * @return List<Map<String,Object>>
     */
    @Override
    @Transactional(readOnly = true)
    public List<Map<String,Object>> getAll(){
        return userSealMapper.getAll();
    }


    /**
     * 根据输入信息进行模糊查询
     * @param userName
     * @param userAccount
     * @param sealTime
     * @return List<Map<String,Object>>
     */
    @Override
    @Transactional(readOnly = true)
    public List<Map<String,Object>> getAllByLike(
            String userName,
            String userAccount,
            String sealTime){
        return userSealMapper.getAllByLike(
                userName,
                userAccount,
                sealTime);
    }


    /**
     * 修改用户封号状态
     * @param sealId
     * @param sealState
     * @throws Exception
     */
    @Override
    public void upUserSeal(Integer sealId,Integer sealState) throws Exception {
        int num = userSealMapper.upUserSeal(sealId,sealState);
        if (num == 0){
            throw new Exception();
        }
    }


    /**
     * 根据用户id获取封停信息
     * @param userId
     * @return int
     */
    @Override
    @Transactional(readOnly = true)
    public Integer getUserSealId(Integer userId) {
        return userSealMapper.getUserSealId(userId);
    }


    /**
     * 查询封禁日期到天的用户id
     * @return List<Integer>
     */
    @Override
    @Transactional(readOnly = true)
    public List<Integer> getSealIdList(){
        return userSealMapper.getSealIdList();
    }


}
